﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Coldairarrow.Business.Company;
using Coldairarrow.Business.Goods;
using Coldairarrow.Entity.Company;
using Coldairarrow.Entity.DTO;
using Coldairarrow.Entity.Goods;
using Coldairarrow.Entity.Home;
using Coldairarrow.IBusiness.Goods;
using Coldairarrow.Util;
using Microsoft.AspNetCore.Mvc;

namespace Coldairarrow.Api.Controllers.Frontstage
{
    [Route("/Frontstage/[controller]/[action]")]
    public class FTS_HomeController : BaseApiController
    {
        #region DI

        public FTS_HomeController(IBTB_HomeBusiness bTB_HomeBus, IBTB_GoodsTypeBusiness bTB_GoodsTypeBusiness, IBTB_CompanyBusiness bTB_CompanyBus)
        {
            _bTB_HomeBus = bTB_HomeBus;
            _bTB_CompanyBus = bTB_CompanyBus;
            _bTB_GoodsTypeBusiness = bTB_GoodsTypeBusiness;
        }

        IBTB_HomeBusiness _bTB_HomeBus;
        IBTB_CompanyBusiness _bTB_CompanyBus { get; }

        IBTB_GoodsTypeBusiness _bTB_GoodsTypeBusiness;

        #endregion

        /// <summary>
        /// 首页模糊查询
        /// </summary>
        /// <param name="GoodsName"></param>
        /// <returns></returns>
        [HttpPost]
        [NoCheckJWT]
        public List<BTB_Goods> GetGoodsName(string GoodsName)
        {
            return _bTB_HomeBus.GetTheDataName(GoodsName);
        }


        /// <summary>
        /// 前台——获取首页分类列表
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        [NoCheckJWT]
        public async Task<PageResult<BTB_GoodsDto>> GetIndexGoodsList(PageInput<GetIndexGoosList> input)
        {
            return await _bTB_HomeBus.GetIndexGoosList(input);
        }

        /// <summary>
        /// 首页热销
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        [NoCheckJWT]
        public async Task<List<BTB_GoodsDto>> GetIsHont()
        {
            return await _bTB_HomeBus.GetIsHont(4);
        }
        /// <summary>
        /// 特惠列表
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        [NoCheckJWT]
        public async Task<List<BTB_GoodsDto>> GetPreferential()
        {
            return await _bTB_HomeBus.GetPreferential(4);
        }
        /// <summary>
        /// 查询所有商品分类
        /// </summary>
        /// <returns></returns>
        [NoCheckJWT]
        [HttpPost]
        public async Task<List<BTB_GoodsTypeDto>> GetAll()
        {
            return await _bTB_HomeBus.GetAll(6);
        }

        /// <summary>
        /// 广告
        /// </summary>
        /// <param name="id">分类id</param>
        /// <returns></returns>
        [NoCheckJWT]
        [HttpPost]
        public async Task<List<BTB_NewProducts>> GetNewProducts(string id)
        {
            return await _bTB_HomeBus.GetNewProducts(id);
        }
        /// <summary>
        /// 前台供应商展示
        /// </summary>
        /// <param name="id">分类id</param>
        /// <returns></returns>
        [NoCheckJWT]
        [HttpPost]
        public async Task<List<BTB_Supplier>> GetGetSupplier(string id)
        {
            return await _bTB_HomeBus.GetSupplier(id);
        }
        /// <summary>
        /// 前台所有商品类型
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        [NoCheckJWT]
        public List<BTB_GoodsType> All()
        {
            return _bTB_GoodsTypeBusiness.All();
        }
        /// <summary>
        /// 首页信息
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        [NoCheckJWT]
        public async Task<BTB_Company> GetTheData()
        {
            return await _bTB_CompanyBus.GetTheDataAsync("1");
        }
        /// <summary>
        /// 首页顶部商品
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        [NoCheckJWT]
        public async Task<List<BTB_GoodsTypeDto>> Get()
        {
            return await _bTB_HomeBus.Get();
        }
    }
}
